import random
from Planete import *
class Etoile(object):
    def __init__(self, x, y, z, numero, proprietaire):
        self.proprietaire=proprietaire
        self.tabPlanetes=[]
        self.tabStructures=[]
        self.x=x
        self.y=y
        self.z=z
        self.numero=numero
        self.nbPlanetes=random.randrange(1,20)
        self.mineraiMax=0
        self.populationMax=0
        self.gazMax=0
        self.minerai=0
        self.population=0
        self.gaz=0
        self.nom="Planete "+str(x)+":"+str(y)+":"+str(z)
        for i in range(0,self.nbPlanetes):
            self.nbRandom=random.randrange(1,3)
            if self.nbRandom == 1:
                typePlanete="Gazeuse"
                planeteGaz=random.randrange(100, 1000)
                planetePopulation=0
                planeteMinerai=0
            if self.nbRandom == 2:
                typePlanete="Habitable"
                planetePopulation=random.randrange(200, 1000)
                planeteMinerai=random.randrange(10, 100)
                planeteGaz=random.randrange(10, 100)
            if self.nbRandom == 3:
                typePlanete="Morte"
                planetePopulation=0
                planeteMinerai=random.randrange(100, 1000)
                planeteGaz=0
            self.tabPlanetes.append(Planete(planeteMinerai, planetePopulation, planeteGaz, type, self))
            self.mineraiMax=self.mineraiMax+planeteMinerai
            self.populationMax=self.populationMax+planetePopulation
            self.gazMax=self.gazMax+planeteGaz
            
    def changerNom(self):
        print "Vous avez decouvert " + self.nom
        self.reponse = raw_input("Voulez-vous lui donner un nom?(o ou n)")
        if self.reponse == "o":
            self.nom=raw_input("Entrez le nom de la planete: ")
        
    
    def creerStationSpatial(self):
        self.tabBatiments.append(Batiment("StationSpatial", self.position, self))
                                 
    def creerCentreEchange(self):
        self.tabBatiments.append(Batiment("CentreEchange", self.position, self))
    
    def creerExtracteurS(self):
        self.tabBatiments.append(Batiment("ExtracteurS", self.position, self))
    
    def creerCMilitaire(self):
        self.tabBatiments.append(Batiment("CMilitaire", self.position, self))
        
    def creerCSciences(self):
        self.tabBatiments.append(Batiment("CSciences", self.position, self))
    
    def creerUAttack(self):
        self.tabBatiments.append(Batiment("UAttack", self.position, self))
    
    def creerUDefense(self):
        self.tabBatiments.append(Batiment("UDefense", self.position, self))